package com.santiao.fuel.utils.UnitConverter;


import static com.santiao.fuel.utils.UnitConverter.CommnetConvertEnum.*;


import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.RequiresApi;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 通用的单位转换类
 */
public class CommmetUnitChange {

    static List<CommnetConvertEnum> units = new ArrayList<>();

    static {
        Collections.addAll(units ,
                MS_KMS,
                MS_KMH,
                MS_LIGHT_SPEED,
                MS_MACH,
                MS_YIN_LI_H,
                MS_YIN_CHI_S,
                KMS_MS,
                KMS_KMH,
                KMS_LIGHT_SPEED,
                KMS_MACH,
                KMS_YIN_LI_H,
                KMS_YIN_CHI_S,
                KMH_MS,
                KMH_KMS,
                KMH_LIGHT_SPEED,
                KMH_MACH,
                KMH_YIN_LI_H,
                KMH_YIN_CHI_S,
                LIGHT_SPEED_MS,
                LIGHT_SPEED_KMS,
                LIGHT_SPEED_KMH,
                LIGHT_SPEED_MACH,
                LIGHT_SPEED_YIN_LI_H,
                LIGHT_SPEED_YIN_CHI_S,
                MACH_MS,
                MACH_KMS,
                MACH_KMH,
                MACH_LIGHT_SPEED,
                MACH_YIN_LI_H,
                MACH_YIN_CHI_S,
                YIN_LI_H_MS,
                YIN_LI_H_KMS,
                YIN_LI_H_KMH,
                YIN_LI_H_LIGHT_SPEED,
                YIN_LI_H_MACH,
                YIN_LI_H_YIN_CHI_S,
                YIN_CHI_S_MS,
                YIN_CHI_S_KMS,
                YIN_CHI_S_KMH,
                YIN_CHI_S_LIGHT_SPEED,
                YIN_CHI_S_MACH,
                YIN_CHI_S_YIN_CHI_H,
                LIFANGMI_LFMS,
                LIFANGMI_GONGSHI,
                LIFANGMI_SHISHENG,
                LIFANGMI_FENSHENG,
                LIFANGMI_LISHENG,
                LIFANGMI_LIFANGLIMI_HS,
                LIFANGMI_LIFANGHS,
                LFMS_LIFANGMI,
                LFMS_GONGSHI,
                LFMS_SHISHENG,
                LFMS_FENSHENG,
                LFMS_LISHENG,
                LFMS_LIFANGLIMI_HS,
                LFMS_LIFANGHS,
                GONGSHI_LIFANGMI,
                GONGSHI_LFMS,
                GONGSHI_SHISHENG,
                GONGSHI_FENSHENG,
                GONGSHI_LISHENG,
                GONGSHINGLIMI_HS,
                GONGSHI_LIFANGHS,
                SHISHENG_LIFANGMI,
                SHISHENG_LFMS,
                SHISHENG_GONGSHI,
                SHISHENG_FENSHENG,
                SHISHENG_LISHENG,
                SHISHENG_HS,
                SHISHENG_LIFANGHS,
                FENSHENG_LIFANGMI,
                FENSHENG_LFMS,
                FENSHENG_GONGSHI,
                FENSHENG_SHISHENG,
                FENSHENG_LISHENG,
                FENSHENG_HS,
                FENSHENG_LIFANGHS,
                LISHENG_LIFANGMI,
                LISHENG_LFMS,
                LISHENG_GONGSHI,
                LISHENG_SHISHENG,
                LISHENG_FENSHENG,
                LISHENG_HS,
                LISHENG_LIFANGHS,
                HS_LIFANGMI,
                HS_LFMS,
                HS_GONGSHI,
                HS_SHISHENG,
                HS_FENSHENG,
                HS_LISHENG,
                HS_LIFANGHS,
                LIFANGHS_LIFANGMI,
                LIFANGHS_LFMS,
                LIFANGHS_GONGSHI,
                LIFANGHS_SHISHENG,
                LIFANGHS_FENSHENG,
                LIFANGHS_LISHENG,
                LIFANGHS_HS,
                YEAR_QUARTER,
                YEAR_MONTH,
                YEAR_WEEK,
                YEAR_DAY,
                YEAR_HOUR,
                YEAR_MINUTE,
                YEAR_SECOND,
                YEAR_MILLISECOND,
                YEAR_MICROSECOND,
                YEAR_NANOSECOND,
                QUARTER_YEAR,
                QUARTER_TO_MONTH,
                QUARTER_TO_WEEK,
                QUARTER_TO_DAY,
                QUARTER_TO_HOUR,
                QUARTER_TO_MINUTE,
                QUARTER_TO_SECOND,
                QUARTER_TO_MILLISECOND,
                QUARTER_TO_MICROSECOND,
                QUARTER_TO_NANOSECOND,
                MONTH_TO_YEAR,
                MONTH_TO_QUARTER,
                MONTH_TO_WEEK,
                MONTH_TO_DAY,
                MONTH_TO_HOUR,
                MONTH_TO_MINUTE,
                MONTH_TO_SECOND,
                MONTH_TO_MILLISECOND,
                MONTH_TO_MICROSECOND,
                MONTH_TO_NANOSECOND,
                WEEK_YEAR,
                WEEK_QUARTER,
                WEEK_MONTH,
                WEEK_DAY,
                WEEK_HOUR,
                WEEK_MINUTE,
                WEEK_SECOND,
                WEEK_MILLISECOND,
                WEEK_MICROSECOND,
                WEEK_NANOSECOND,
                DAY_YEAR,
                DAY_QUARTER,
                DAY_MONTH,
                DAY_WEEK,
                DAY_HOUR,
                DAY_MINUTE,
                DAY_SECOND,
                DAY_MILLISECOND,
                DAY_MICROSECOND,
                DAY_NANOSECOND,
                HOUR_YEAR,
                HOUR_QUARTER,
                HOUR_MONTH,
                HOUR_WEEK,
                HOUR_DAY,
                HOUR_MINUTE,
                HOUR_SECOND,
                HOUR_MILLISECOND,
                HOUR_MICROSECOND,
                HOUR_NANOSECOND,
                MINUTE_YEAR,
                MINUTE_QUARTER,
                MINUTE_MONTH,
                MINUTE_WEEK,
                MINUTE_DAY,
                MINUTE_HOUR,
                MINUTE_SECOND,
                MINUTE_MILLISECOND,
                MINUTE_MICROSECOND,
                MINUTE_NANOSECOND,
                SECOND_YEAR,
                SECOND_QUARTER,
                SECOND_MONTH,
                SECOND_WEEK,
                SECOND_DAY,
                SECOND_HOUR,
                SECOND_MINUTE,
                SECOND_MILLISECOND,
                SECOND_MICROSECOND,
                SECOND_NANOSECOND,
                MILLISECOND_YEAR,
                MILLISECOND_QUARTER,
                MILLISECOND_MONTH,
                MILLISECOND_WEEK,
                MILLISECOND_DAY,
                MILLISECOND_HOUR,
                MILLISECOND_MINUTE,
                MILLISECOND_SECOND,
                MILLISECOND_MICROSECOND,
                MILLISECOND_NANOSECOND,
                MICROSECOND_YEAR,
                MICROSECOND_QUARTER,
                MICROSECOND_MONTH,
                MICROSECOND_WEEK,
                MICROSECOND_DAY,
                MICROSECOND_HOUR,
                MICROSECOND_MINUTE,
                MICROSECOND_SECOND,
                MICROSECOND_MILLISECOND,
                MICROSECOND_NANOSECOND,
                NANOSECOND_YEAR,
                NANOSECOND_QUARTER,
                NANOSECOND_MONTH,
                NANOSECOND_WEEK,
                NANOSECOND_DAY,
                NANOSECOND_HOUR,
                NANOSECOND_MINUTE,
                NANOSECOND_SECOND,
                NANOSECOND_MILLISECOND,
                NANOSECOND_MICROSECOND,

                // 长度单位
                KILOMETER_METER,
                KILOMETER_DECIMETER,
                KILOMETER_CENTIMETER,
                KILOMETER_MILLIMETER,
                KILOMETER_MICROMETER,
                KILOMETER_NANOMETER,
                KILOMETER_PICO_METER,
                KILOMETER_LI,
                KILOMETER_ZHANG,
                KILOMETER_CHI,
                KILOMETER_CUN,
                KILOMETER_FEN,
                KILOMETER_LI_CM,
                KILOMETER_MAO,
                KILOMETER_MILE,
                KILOMETER_FOOT,
                KILOMETER_INCH,
                KILOMETER_NAUTICAL_MILE,
                METER_KILOMETER,
                METER_DECIMETER,
                METER_CENTIMETER,
                METER_MILLIMETER,
                METER_MICROMETER,
                METER_NANOMETER,
                METER_PICO_METER,
                METER_LI,
                METER_ZHANG,
                METER_CHI,
                METER_CUN,
                METER_FEN,
                METER_LI_CM,
                METER_MAO,
                METER_MILE,
                METER_FOOT,
                METER_INCH,
                METER_NAUTICAL_MILE,
                DECIMETER_KILOMETER,
                DECIMETER_METER,
                DECIMETER_CENTIMETER,
                DECIMETER_MILLIMETER,
                DECIMETER_MICROMETER,
                DECIMETER_NANOMETER,
                DECIMETER_PICO_METER,
                DECIMETER_LI,
                DECIMETER_ZHANG,
                DECIMETER_CHI,
                DECIMETER_CUN,
                DECIMETER_FEN,
                DECIMETER_LI_CM,
                DECIMETER_MAO,
                DECIMETER_MILE,
                DECIMETER_FOOT,
                DECIMETER_INCH,
                DECIMETER_NAUTICAL_MILE,
                CENTIMETER_KILOMETER,
                CENTIMETER_METER,
                CENTIMETER_DECIMETER,
                CENTIMETER_MILLIMETER,
                CENTIMETER_MICROMETER,
                CENTIMETER_NANOMETER,
                CENTIMETER_PICO_METER,
                CENTIMETER_LI,
                CENTIMETER_ZHANG,
                CENTIMETER_CHI,
                CENTIMETER_CUN,
                CENTIMETER_FEN,
                CENTIMETER_LI_CM,
                CENTIMETER_MAO,
                CENTIMETER_MILE,
                CENTIMETER_FOOT,
                CENTIMETER_INCH,
                CENTIMETER_NAUTICAL_MILE,
                MILLIMETER_KILOMETER,
                MILLIMETER_METER,
                MILLIMETER_DECIMETER,
                MILLIMETER_CENTIMETER,
                MILLIMETER_MICROMETER,
                MILLIMETER_NANOMETER,
                MILLIMETER_PICO_METER,
                MILLIMETER_LI,
                MILLIMETER_ZHANG,
                MILLIMETER_CHI,
                MILLIMETER_CUN,
                MILLIMETER_FEN,
                MILLIMETER_LI_CM,
                MILLIMETER_MAO,
                MILLIMETER_MILE,
                MILLIMETER_FOOT,
                MILLIMETER_INCH,
                MILLIMETER_NAUTICAL_MILE,
                MICROMETER_KILOMETER,
                MICROMETER_METER,
                MICROMETER_DECIMETER,
                MICROMETER_CENTIMETER,
                MICROMETER_MILLIMETER,
                MICROMETER_NANOMETER,
                MICROMETER_PICO_METER,
                MICROMETER_LI,
                MICROMETER_ZHANG,
                MICROMETER_CHI,
                MICROMETER_CUN,
                MICROMETER_FEN,
                MICROMETER_LI_CM,
                MICROMETER_MAO,
                MICROMETER_MILE,
                MICROMETER_FOOT,
                MICROMETER_INCH,
                MICROMETER_NAUTICAL_MILE,
                NANOMETER_KILOMETER,
                NANOMETER_METER,
                NANOMETER_DECIMETER,
                NANOMETER_CENTIMETER,
                NANOMETER_MILLIMETER,
                NANOMETER_MICROMETER,
                NANOMETER_PICO_METER,
                NANOMETER_LI,
                NANOMETER_ZHANG,
                NANOMETER_CHI,
                NANOMETER_CUN,
                NANOMETER_FEN,
                NANOMETER_LI_CM,
                NANOMETER_MAO,
                NANOMETER_MILE,
                NANOMETER_FOOT,
                NANOMETER_INCH,
                NANOMETER_NAUTICAL_MILE,
                PM_KM,
                PM_M,
                PM_DM,
                PM_CM,
                PM_MM,
                PM_UM,
                PM_NM,
                PM_LI,
                PM_ZHANG,
                PM_CHI,
                PM_CUN,
                PM_FEN,
                PM_MAO,
                PM_MI,
                PM_FEET,
                PM_INCH,
                PM_NAUTICAL_MILE,
                LI_KM,
                LI_M,
                LI_DM,
                LI_CM,
                LI_MM,
                LI_UM,
                LI_NM,
                LI_PM,
                LI_ZHANG,
                LI_CHI,
                LI_CUN,
                LI_FEN,
                LI_LI,
                LI_MAO,
                LI_MI,
                LI_FEET,
                LI_INCH,
                LI_NAUTICAL_MILE,
                ZHANG_KM,
                ZHANG_M,
                ZHANG_DM,
                ZHANG_CM,
                ZHANG_MM,
                ZHANG_UM,
                ZHANG_NM,
                ZHANG_PM,
                ZHANG_LI,
                ZHANG_CHI,
                ZHANG_CUN,
                ZHANG_FEN,
                ZHANG_MAO,
                ZHANG_MI,
                ZHANG_FEET,
                ZHANG_INCH,
                ZHANG_NAUTICAL_MILE,
                CHI_KM,
                CHI_M,
                CHI_DM,
                CHI_CM,
                CHI_MM,
                CHI_UM,
                CHI_NM,
                CHI_PM,
                CHI_LI,
                CHI_ZHANG,
                CHI_CUN,
                CHI_FEN,
                CHI_MAO,
                CHI_MI,
                CHI_FEET,
                CHI_INCH,
                CHI_NAUTICAL_MILE,
                CUN_KM,
                CUN_M,
                CUN_DM,
                CUN_CM,
                CUN_MM,
                CUN_UM,
                CUN_NM,
                CUN_PM,
                CUN_LI,
                CUN_ZHANG,
                CUN_CHI,
                CUN_FEN,
                CUN_MAO,
                CUN_MI,
                CUN_FEET,
                CUN_INCH,
                CUN_NAUTICAL_MILE,
                FEN_KM,
                FEN_M,
                FEN_DM,
                FEN_CM,
                FEN_MM,
                FEN_UM,
                FEN_NM,
                FEN_PM,
                FEN_LI,
                FEN_ZHANG,
                FEN_CHI,
                FEN_CUN,
                FEN_MAO,
                FEN_MI,
                FEN_FEET,
                FEN_INCH,
                FEN_NAUTICAL_MILE,
                MAO_KM,
                MAO_M,
                MAO_DM,
                MAO_CM,
                MAO_MM,
                MAO_UM,
                MAO_NM,
                MAO_PM,
                MAO_LI,
                MAO_ZHANG,
                MAO_CHI,
                MAO_CUN,
                MAO_FEN,
                MAO_MI,
                MAO_FEET,
                MAO_INCH,
                MAO_NAUTICAL_MILE,
                MI_KM,
                MI_M,
                MI_DM,
                MI_CM,
                MI_MM,
                MI_UM,
                MI_NM,
                MI_PM,
                MI_LI,
                MI_ZHANG,
                MI_CHI,
                MI_CUN,
                MI_FEN,
                MI_MAO,
                MI_FEET,
                MI_INCH,
                MI_NAUTICAL_MILE,
                FOOT_KILOMETER,
                FOOT_METER,
                FOOT_DECIMETER,
                FOOT_CENTIMETER,
                FOOT_MILLIMETER,
                FOOT_MICROMETER,
                FOOT_NANOMETER,
                FOOT_PICOMETER,
                FOOT_LI,
                FOOT_ZHANG,
                FOOT_CHI,
                FOOT_CUN,
                FOOT_FEN,
                FOOT_LIAO,
                FOOT_HAO,
                FOOT_MILE,
                FOOT_INCH,
                FOOT_NAUTICAL_MILE,
                INCH_KILOMETER,
                INCH_METER,
                INCH_DECIMETER,
                INCH_CENTIMETER,
                INCH_MILLIMETER,
                INCH_MICROMETER,
                INCH_NANOMETER,
                INCH_PICO_METER,
                INCH_LI,
                INCH_ZHANG,
                INCH_CHI,
                INCH_CUN,
                INCH_FEN,
                INCH_LI_CM,
                INCH_MAO,
                INCH_MILE,
                INCH_FOOT,
                INCH_NAUTICAL_MILE,
                NAUTICAL_MILE_KILOMETER,
                NAUTICAL_MILE_METER,
                NAUTICAL_MILE_DECIMETER,
                NAUTICAL_MILE_CENTIMETER,
                NAUTICAL_MILE_MILLIMETER,
                NAUTICAL_MILE_MICROMETER,
                NAUTICAL_MILE_NANOMETER,
                NAUTICAL_MILE_PICO_METER,
                NAUTICAL_MILE_LI,
                NAUTICAL_MILE_ZHANG,
                NAUTICAL_MILE_CHI,
                NAUTICAL_MILE_CUN,
                NAUTICAL_MILE_FEN,
                NAUTICAL_MILE_LI_CM,
                NAUTICAL_MILE_MAO,
                NAUTICAL_MILE_MILE,
                NAUTICAL_MILE_FOOT,
                NAUTICAL_MILE_INCH,

//   重量
                TON_KG,
                TON_G,
                TON_MG,
                TON_UG,
                TON_GD,
                TON_CT,
                TON_FEN,
                TON_JIN,
                TON_DAN,
                TON_LIANG,
                TON_QIAN,
                TON_TROY_POUND,
                TON_TROY_OUNCE,
                TON_ENGLISH_PENCE,
                TON_GRAIN,
                TON_LONG_TON,
                TON_SHORT_TON,
                TON_UK_QUARTER,
                TON_US_QUARTER,
                TON_POUND,
                TON_OUNCE,
                TON_STONE,
                TON_GRAIN_AV,

                KILOGRAM_FEN,
                KILOGRAM_GRAIN_A,
                KILOGRAM_GRAM,
                KILOGRAM_MILLIGRAM,
                KILOGRAM_MICROGRAM,
                KILOGRAM_TON,
                KILOGRAM_PUBLIC_QUINTAL,
                KILOGRAM_CARAT,
                KILOGRAM_LIANG,
                KILOGRAM_QIAN,
                KILOGRAM_TROY_POUND,
                KILOGRAM_TROY_OUNCE,
                KILOGRAM_ENGLISH_PENCE,
                KILOGRAM_GRAIN,
                KILOGRAM_LONG_TON,
                KILOGRAM_SHORT_TON,
                KILOGRAM_UK_QUINTAL,
                KILOGRAM_US_QUINTAL,
                KILOGRAM_POUND,
                KILOGRAM_OUNCE,
                KILOGRAM_DAN,
                KILOGRAM_JIN,
                KILOGRAM_DAN_WEIGHT,

                GRAM_KG,
                GRAM_MG,
                GRAM_UG,
                GRAM_TON,
                GRAM_PUBLIC_DAN,
                GRAM_CARAAT,
                GRAM_FEN,
                GRAM_JIN,
                GRAM_DAN,
                GRAM_LIANG,
                GRAM_QIAN,
                GRAM_TROY_POUND,
                GRAM_TROY_OUNCE,
                GRAM_ENGLISH_PENCE,
                GRAM_GRAIN,
                GRAM_LONG_TON,
                GRAM_SHORT_TON,
                GRAM_UK_QUARTER,
                GRAM_US_QUARTER,
                GRAM_POUND,
                GRAM_OUNCE,
                GRAM_DALAN,
                GRAM_GRAM,

                MILLIGRAM_GRAM,
                MILLIGRAM_MICROGRAM,
                MILLIGRAM_TON,
                MILLIGRAM_PUBLIC_UNIT,
                MILLIGRAM_CARAT,
                MILLIGRAM_FEN,
                MILLIGRAM_JIN,
                MILLIGRAM_DAN,
                MILLIGRAM_LIANG,
                MILLIGRAM_QIAN,
                MILLIGRAM_TROY_POUND,
                MILLIGRAM_TROY_OUNCE,
                MILLIGRAM_ENGLISH_PENCE,
                MILLIGRAM_GRAIN,
                MILLIGRAM_LONG_TON,
                MILLIGRAM_SHORT_TON,
                MILLIGRAM_ENGLISH_HUNDREDWEIGHT,
                MILLIGRAM_US_HUNDREDWEIGHT,
                MILLIGRAM_POUND,
                MILLIGRAM_OUNCE,
                MILLIGRAM_DARLING,
                MILLIGRAM_ENGLISH_GRAIN,
                MILLIGRAM_GRAMME,
                MICROGRAM_GRAM,
                MICROGRAM_KILOGRAM,
                MICROGRAM_TON,
                MICROGRAM_QIAN_DAN,
                MICROGRAM_KARA,
                MICROGRAM_FEN,
                MICROGRAM_JIN,
                MICROGRAM_DAN,
                MICROGRAM_LIANG,
                MICROGRAM_QIAN,
                MICROGRAM_TROY_POUND,
                MICROGRAM_TROY_OUNCE,
                MICROGRAM_ENGLISH_PENCE,
                MICROGRAM_GRAIN,
                MICROGRAM_LONG_TON,
                MICROGRAM_SHORT_TON,
                MICROGRAM_UK_QUARTER,
                MICROGRAM_US_QUARTER,
                MICROGRAM_POUND,
                MICROGRAM_OUNCE,
                MICROGRAM_STONE,
                MICROGRAM_ENGLISH_GRAIN,
                MICROGRAM_KILOGRAM_ALT,
                MICROGRAM_MILLIGRAM,


                GONG_DAN_KRAT,
                GONG_DAN_FEN,
                GONG_DAN_JIN,
                GONG_DAN_DAN,
                GONG_DAN_LIANG,
                GONG_DAN_QIAN,
                GONG_DAN_TROY_POUND,
                GONG_DAN_TROY_OUNCE,
                GONG_DAN_ENGLISH_PENCE,
                GONG_DAN_GRAIN_TROY,
                GONG_DAN_LONG_TON,
                GONG_DAN_SHORT_TON,
                GONG_DAN_UK_QUARTER,
                GONG_DAN_US_QUARTER,
                GONG_DAN_POUND,
                GONG_DAN_OUNCE,
                GONG_DAN_TALENT,
                GONG_DAN_GRAIN_AVDP,
                GONG_DAN_GRAM,
                GONG_DAN_MILLIGRAM,
                GONG_DAN_MICROGRAM,
                GONG_DAN_KILOGRAM,
                GONG_DAN_TONNE,


                CARAT_GRAM,
                CARAT_DECIGRAM,
                CARAT_CENTIGRAM,
                CARAT_MILLIGRAM,
                CARAT_MICROGRAM,
                CARAT_NANOKRAM,
                CARAT_PICOKRAM,
                CARAT_JIN,
                CARAT_DAN,
                CARAT_LIANG,
                CARAT_QIAN,
                CARAT_TROY_POUND,
                CARAT_TROY_OUNCE,
                CARAT_ENGLISH_POUND,
                CARAT_ENGLISH_OUNCE,
                CARAT_GRAIN,
                CARAT_LONG_TON,
                CARAT_SHORT_TON,
                CARAT_ENGLISH_STONE,
                CARAT_US_STONE,
                CARAT_DRAM,
                CARAT_KILOGRAM,
                CARAT_TON,
                CARAT_PUBLIC_DAN,


                FEN_JIN,
                FEN_DAN,
                FEN_LIANG,
                FEN_QIAN,
                FEN_TROY_POUND,
                FEN_TROY_OUNCE,
                FEN_ENGLISH_PENCE,
                FEN_GRAM,
                FEN_LONG_TON,
                FEN_SHORT_TON,
                FEN_UK_QUARTER,
                FEN_US_QUARTER,
                FEN_POUND,
                FEN_OUNCE,
                FEN_STONE,
                FEN_GRAIN,
                FEN_GRAMME,
                FEN_MILLIGRAMME,
                FEN_MICROGRAMME,
                FEN_KILOGRAMME,
                FEN_TONNE,
                FEN_QUINTAL,
                FEN_CARAT,

                JIN_DAN,
                JIN_LIANG,
                JIN_QIAN,
                JIN_TROY_POUND,
                JIN_TROY_OUNCE,
                JIN_ENGLISH_PENCE,
                JIN_GRAM,
                JIN_MILLIGRAM,
                JIN_MICROGRAM,
                JIN_KILOGRAM,
                JIN_TON,
                JIN_PUBLIC_DAN,
                JIN_CARAT,
                JIN_FEN,
                JIN_TROY_GRAIN,
                JIN_LONG_TON,
                JIN_SHORT_TON,
                JIN_ENGLISH_DAN,
                JIN_US_DAN,
                JIN_POUND,
                JIN_OUNCE,
                JIN_STONE,
                JIN_ENGLISH_GRAIN,

                DAN_QIAN,
                DAN_GOLD_POUND,
                DAN_GOLD_OUNCE,
                DAN_ENGLISH_PENCE,
                DAN_GOLD_GRAIN,
                DAN_LONG_TON,
                DAN_SHORT_TON,
                DAN_ENGLISH_STONE,
                DAN_US_STONE,
                DAN_POUND,
                DAN_OUNCE,
                DAN_DRAM,
                DAN_GRAIN,
                DAN_GRAM,
                DAN_MILLIGRAM,
                DAN_MICROGRAM,
                DAN_KILOGRAM,
                DAN_TON,
                DAN_PUBLIC_KILOGRAM,
                DAN_CARAT,
                DAN_FEN,
                DAN_JIN,
                TWO_MONEY_GOLD_POUND,
                TWO_MONEY_GOLD_OUNCE,
                TWO_MONEY_ENGLISH_PENCE,
                TWO_MONEY_GOLD_GRAIN,
                TWO_MONEY_LONG_TON,
                TWO_MONEY_SHORT_TON,
                TWO_MONEY_ENGLISH_HUNDREDWEIGHT,
                TWO_MONEY_US_HUNDREDWEIGHT,
                TWO_MONEY_POUND,
                TWO_MONEY_OUNCE,
                TWO_MONEY_DRAKE,
                TWO_MONEY_GRAIN,
                TWO_MONEY_GRAM,
                TWO_MONEY_MILLIGRAM,
                TWO_MONEY_MICROGRAM,
                TWO_MONEY_KILOGRAM,
                TWO_MONEY_TON,
                TWO_MONEY_PUBLIC_HUNDREDWEIGHT,
                TWO_MONEY_CARAT,
                TWO_MONEY_FEN,
                TWO_MONEY_JIN,
                TWO_MONEY_DAN,
                QIAN_JINBENG_POUND,
                QIAN_JINBENG_OUNCE,
                QIAN_EN_QIAN,
                QIAN_JINBENG_GRAIN,
                QIAN_EN_LONG_TON,
                QIAN_US_SHORT_TON,
                QIAN_EN_CWT,
                QIAN_US_CWT,
                QIAN_POUND,
                QIAN_OUNCE,
                QIAN_DALEN,
                QIAN_GRAIN,
                QIAN_GRAM,
                QIAN_MILLIGRAM,
                QIAN_MICROGRAM,
                QIAN_KILOGRAM,
                QIAN_TON,
                QIAN_GONGDAN,
                QIAN_KARA,
                QIAN_FEN,
                QIAN_JIN,
                QIAN_DAN,
                QIAN_LIANG,
                OZ_TROY_PENCE,
                OZ_TROY_GRAIN,
                OZ_TROY_LONG_TON,
                OZ_TROY_SHORT_TON,
                OZ_TROY_CWT_UK,
                OZ_TROY_CWT_US,
                OZ_TROY_POUND,
                OZ_TROY_OUNCE,
                OZ_TROY_DRAUGHT,
                OZ_TROY_GRAIN_IMPERIAL,
                OZ_TROY_GRAM,
                OZ_TROY_MILLIGRAM,
                OZ_TROY_MICROGRAM,
                OZ_TROY_KILOGRAM,
                OZ_TROY_METRIC_TON,
                OZ_TROY_HECTOGRAM,
                OZ_TROY_CARAT,
                OZ_TROY_POINT,
                OZ_TROY_JIN,
                OZ_TROY_DAN,
                OZ_TROY_LIANG,
                OZ_TROY_QIAN,
                OZ_TROY_POUND_TROY,
                PENCE_GRAM,
                PENCE_LONG_TON,
                PENCE_SHORT_TON,
                PENCE_HUNDREDWEIGHT,
                PENCE_CWT,
                PENCE_POUND,
                PENCE_OUNCE,
                PENCE_DRAM,
                PENCE_GRAIN,
                PENCE_GRAM2,
                PENCE_MILLIGRAM,
                PENCE_MICROGRAM,
                PENCE_KILOGRAM,
                PENCE_TON,
                PENCE_QINTAL,
                PENCE_CARAT,
                PENCE_POINT,
                PENCE_JIN,
                PENCE_DAN,
                PENCE_LIANG,
                PENCE_QIAN,
                PENCE_TROY_POUND,
                PENCE_TROY_OUNCE,
                GRAIN_LONG_TON,
                GRAIN_SHORT_TON,
                GRAIN_BUSHEL,
                GRAIN_US_BUSHEL,
                GRAIN_POUND,
                GRAIN_OUNCE,
                GRAIN_DRAM,
                GRAIN_GRAIN,
                GRAIN_GRAM,
                GRAIN_MILLIGRAM,
                GRAIN_MICROGRAM,
                GRAIN_KILOGRAM,
                GRAIN_TONNE,
                GRAIN_QINTAL,
                GRAIN_CARAT,
                GRAIN_FEN,
                GRAIN_JIN,
                GRAIN_DAN,
                GRAIN_LIANG,
                GRAIN_QIAN,
                GRAIN_TROY_POUND,
                GRAIN_TROY_OUNCE,
                GRAIN_ENGLISH_PENCE,
                IMPERIAL_TON_US_SHORT_TON,
                IMPERIAL_TON_UK_QUARTER,
                IMPERIAL_TON_US_QUARTER,
                IMPERIAL_TON_POUND,
                IMPERIAL_TON_OUNCE,
                IMPERIAL_TON_BARREL,
                IMPERIAL_TON_GRAIN,
                IMPERIAL_TON_GRAM,
                IMPERIAL_TON_MILLIGRAM,
                IMPERIAL_TON_MICROGRAM,
                IMPERIAL_TON_KILOGRAM,
                IMPERIAL_TON_METRIC_TON,
                IMPERIAL_TON_HECTOGRAM,
                IMPERIAL_TON_CARAT,
                IMPERIAL_TON_FEN,
                IMPERIAL_TON_JIN,
                IMPERIAL_TON_DAN,
                IMPERIAL_TON_LIANG,
                IMPERIAL_TON_QIAN,
                IMPERIAL_TON_TROY_POUND,
                IMPERIAL_TON_TROY_OUNCE,
                IMPERIAL_TON_TROY_PENNYWEIGHT,
                IMPERIAL_TON_TROY_GRAIN,
                SHORT_TON_UK_QUARTER,
                SHORT_TON_UK_CWT,
                SHORT_TON_UK_POUND,
                SHORT_TON_UK_OUNCE,
                SHORT_TON_UK_STONE,
                SHORT_TON_UK_GRAIN,
                SHORT_TON_UK_GRAM,
                SHORT_TON_UK_MILLIGRAM,
                SHORT_TON_UK_MICROGRAM,
                SHORT_TON_UK_KILOGRAM,
                SHORT_TON_UK_METRIC_TON,
                SHORT_TON_UK_HUNDREDWEIGHT,
                SHORT_TON_UK_CARAT,
                SHORT_TON_UK_POINT,
                SHORT_TON_UK_JIN,
                SHORT_TON_UK_DAN,
                SHORT_TON_UK_LIANG,
                SHORT_TON_UK_QIAN,
                SHORT_TON_UK_TROY_POUND,
                SHORT_TON_UK_TROY_OUNCE,
                SHORT_TON_UK_ENGLISH_PENCE,
                SHORT_TON_UK_TROY_GRAIN,
                SHORT_TON_UK_LONG_TON,
                UK_BOLL_TO_US_BOLL,
                UK_BOLL_TO_POUND,
                UK_BOLL_TO_OUNCE,
                UK_BOLL_TO_PECK,
                UK_BOLL_TO_GRAIN,
                UK_BOLL_TO_GRAM,
                UK_BOLL_TO_MILLIGRAM,
                UK_BOLL_TO_MICROGRAM,
                UK_BOLL_TO_KILOGRAM,
                UK_BOLL_TO_TON,
                UK_BOLL_TO_QUINTAL,
                UK_BOLL_TO_CARAT,
                UK_BOLL_TO_FEN,
                UK_BOLL_TO_JIN,
                UK_BOLL_TO_DAN,
                UK_BOLL_TO_LIANG,
                UK_BOLL_TO_QIAN,
                UK_BOLL_TO_TROY_POUND,
                UK_BOLL_TO_TROY_OUNCE,
                UK_BOLL_TO_ENGLISH_PENCE,
                UK_BOLL_TO_TROY_GRAIN,
                UK_BOLL_TO_LONG_TON,
                UK_BOLL_TO_SHORT_TON,

                MEIDAN_LB,
                MEIDAN_OZ,
                MEIDAN_DALAN,
                MEIDAN_GRAIN,
                MEIDAN_G,
                MEIDAN_MG,
                MEIDAN_UG,
                MEIDAN_KG,
                MEIDAN_TON,
                MEIDAN_GDAN,
                MEIDAN_CT,
                MEIDAN_FEN,
                MEIDAN_JIN,
                MEIDAN_DAN,
                MEIDAN_LIANG,
                MEIDAN_QIAN,
                MEIDAN_AVDPND,
                MEIDAN_AVOZ,
                MEIDAN_ENPENCE,
                MEIDAN_ENGRAIN,
                MEIDAN_LTON,
                MEIDAN_STON,
                MEIDAN_UKQTR,

                POUND_OUNCE,
                POUND_DRAM,
                POUND_GRAIN,
                POUND_GRAM,
                POUND_MILLIGRAM,
                POUND_MICROGRAM,
                POUND_KILOGRAM,
                POUND_TON,
                POUND_QIAN,
                POUND_CARRAT,
                POUND_FEN,
                POUND_JIN,
                POUND_DAN,
                POUND_LIANG,
                POUND_QIAN2,
                POUND_TROY_POUND,
                POUND_TROY_OUNCE,
                POUND_PENCE,
                POUND_TROY_GRAIN,
                POUND_LONG_TON,
                POUND_SHORT_TON,
                POUND_UK_QUARTER,
                POUND_US_QUARTER,

                OZ_OZ,
                OZ_DRAM,
                OZ_GRAIN,
                OZ_GRAM,
                OZ_MILLIGRAM,
                OZ_MICROGRAM,
                OZ_KILOGRAM,
                OZ_TON,
                OZ_QIAN,
                OZ_CARAT,
                OZ_FEN,
                OZ_JIN,
                OZ_DAN,
                OZ_LIANG,
                OZ_QIAN_UNIT,
                OZ_TROY_OZ,
                OZ_ENGLISH_PENCE,
                OZ_LONG_TON,
                OZ_SHORT_TON,
                OZ_ENGLISH_HUNDREDWEIGHT,
                OZ_US_HUNDREDWEIGHT,
                OZ_POUND,
                DALAN_GRAM,
                DALAN_KILOGRAM,
                DALAN_MILLIGRAM,
                DALAN_MICROGRAM,
                DALAN_GRAM_KG,
                DALAN_TON,
                DALAN_PUBLIC_KILOGRAM,
                DALAN_CARAT,
                DALAN_FEN,
                DALAN_JIN,
                DALAN_DAN,
                DALAN_LIANG,
                DALAN_QIAN,
                DALAN_TROY_POUND,
                DALAN_TROY_OUNCE,
                DALAN_ENGLISH_PENCE,
                DALAN_TROY_GRAIN,
                DALAN_LONG_TON,
                DALAN_SHORT_TON,
                DALAN_ENGLISH_QUARTER,
                DALAN_US_QUARTER,
                DALAN_POUND,
                DALAN_OUNCE,
                GRAIN_TON,
                GRAIN_QIAN2,
                GRAIN_TROY_GRAIN,
                GRAIN_ENGLISH_QUARTER,
                GRAIN_US_QUARTER,
                GRAIN_STONE,
                GRAM_MILLIGRAM,
                GRAM_MICROGRAM,
                GRAM_KILOGRAM,
                GRAM_QIAN2,
                GRAM_TROY_GRAIN,
                GRAM_ENGLISH_QUARTER,
                MG_MG,
                MG_UG,
                MG_KG,
                MG_TON,
                MG_GD,
                MG_CT,
                MG_FEN,
                MG_JIN,
                MG_DAN,
                MG_LIANG,
                MG_QIAN,
                MG_AVDP_LB,
                MG_AVDP_OZ,
                MG_TROY_GR,
                MG_GRAIN,
                MG_LONG_TON,
                MG_SHORT_TON,
                MG_UK_QTR,
                MG_US_QTR,
                MG_LB,
                MG_OZ,
                MG_DALTON,
                MG_G
                );
    }


    private final static String DIV = "div";


    private final static  String RIDER = "rider";


    /**
     * 单位转换方法
     * @param fromUnit  转换之前的单位
     * @param toUnit 转换之后的单位
     * @param value 转换之前的数字
     * @return  返回转换之后的数字
     */
    @RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
    public static BigDecimal ChangeUnits (String fromUnit , String toUnit , BigDecimal value, Context context){

        BigDecimal res = new BigDecimal(0);
        if (fromUnit.equals(toUnit) || fromUnit == toUnit){
            return value;
        }

        List<CommnetConvertEnum> collect = units.stream().filter(item -> item.getFromUnit().equals(fromUnit) && item.getToUnit().equals(toUnit))
                .collect(Collectors.toUnmodifiableList());

        if (collect==null || collect.size() == 0){
            Toast.makeText(context , "error" ,Toast.LENGTH_SHORT).show();
            return res;
        }
        CommnetConvertEnum commnetConvertEnum =collect.get(0);

        if (commnetConvertEnum == null) {
            Log.d("TAG", "ChangeUnits: 没有这个类型的转换器");
            return value;
        }else {
            String method = commnetConvertEnum.getMethod();
            String space = commnetConvertEnum.getSpace();

            if (DIV.equals(method)) {
                res = value.divide(new BigDecimal(space));
            } else if (RIDER.equals(method)) {
                res = value.multiply(new BigDecimal(space));
            }
        }

        return res;
    }
}
